let { CleanWebpackPlugin } = require('clean-webpack-plugin')
let html = require('html-webpack-plugin')
let cssMiniExtract = require('mini-css-extract-plugin')
let path = require('path')
let Plugin1 = require('./plugins/plugin1')
module.exports = {
  entry: {
    //多入口
    index123: './src/index.js',
    other123: './src/other.js'
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].[contenthash:6].js'
  },
  plugins: [
    new Plugin1({
      q: 1, w: 2
    }),
    new CleanWebpackPlugin(),
    new html({
      template: './public/index.html',
      filename: 'index.html',
      chunks: ['index123']
    }),
    new html({
      template: './public/other.html',
      filename: 'other.html',
      chunks: ['other123']
    }),
    new cssMiniExtract()
  ],
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [cssMiniExtract.loader, 'css-loader'],
        exclude: /node_modules/
      },
      {
        test: /\.js$/,
        use: ['babel-loader']
      }
    ]
  }
}